'
' This program is free software; you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation; either version 2 of the License, or
' (at your option) any later version.
' 
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
' GNU General Public License for more details.
' 
' You should have received a copy of the GNU General Public License
' along with this program; if not, write to the Free Software
' Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
' MA 02110-1301, USA.
' 
' ======================================================================
' Create new folder based on timestamp
' 
' @usage mkdt.vbs [file]
' if parameter file is not specified, new folder in current folder
' will be created. Otherwise it will create new folder in file's folder
' ======================================================================

Dim oNomads, oFSO, oFolder, oFile, oShell
Dim cFilePath, cFolderPath

Set oNomads = New Nomads
Set oFSO = WScript.CreateObject("Scripting.FileSystemObject")
Set oShell = WScript.CreateObject("WScript.Shell")

cFolderPath = oShell.currentDirectory
If WScript.Arguments.Count Then
	cFilePath = WScript.Arguments(0)
	If oFSO.FileExists(cFilePath) Then
		Set oFile = oFSO.getFile(cFilePath)
		cFolderPath = oFile.ParentFolder.Path
	ElseIf oFSO.FolderExists(cFilePath) Then
		Set oFile = oFSO.getFolder(cFilePath)
		cFolderPath = oFile.ParentFolder.Path
	End If
Else
	
End If

' Set oFile = oFSO.getFile(cFilePath)
' WScript.Echo cFolderPath & "\" & oNomads.getCurrentDateTime()
oFso.CreateFolder  cFolderPath & "\" & oNomads.getCurrentDateTime()

Class Nomads

	Function getDateTime(dtNow)
		getDateTime = Year(dtNow) & _
			Me.strPad(Month(dtNow), 2, "0") & _
			Me.strPad(Day(dtNow), 2, "0") & "-" & _
			Me.strPad(Hour(dtNow), 2, "0") & _
			Me.strPad(Minute(dtNow), 2, "0") & _
			Me.strPad(Second(dtNow), 2, "0")
	End Function

	Function getCurrentDateTime
		getCurrentDateTime = Me.getDateTime(Now())
	End Function
	
	Function strPad(cInput, iLenght, cPadString)
		
		Do Until Len(cInput) >= iLenght
			cInput = cPadString & cInput
		Loop
		
		strPad = cInput
	End Function
End Class
